#!/usr/bin/env.python
# _*_ coding:utf-8 _*_
# # # # # # # # # # # # # # # # # # # #
#  题目:      booktest的urls路由       #
#  姓名:         李吉辉                #
#  时间:    2018年12月13日21:22:32     #
# # # # # # # # # # # # # # # # # # # #

from django.conf.urls import url
from rest_framework.routers import DefaultRouter, SimpleRouter


from . import views

urlpatterns = [

    # 获取列表所有数据/新增
    # url(r"^books/$", views.BooksAPIView.as_view()),

    # 查单一/更新和删除
    # url(r"^books/(?P<pk>\d+)/$", views.BookAPIView.as_view())

    # 定义获取所有图书路由(APIView)
    # url(r"^books/$", views.BooksAPiView.as_view()),


    # 定义获取所有图书(GenericAPIView)
    # url(r"^books/$", views.BookListView.as_view()),

    # 定义获取单一图书(GenericAPIView)
    # url(r"^books/(?P<pk>\d+)/$", views.BookDetailView.as_view()),

    # 演示ViewSet视图集
    # url(r"^books/$", views.BookViewSet.as_view({"get": "list"})),
    # url(r"^books/(?P<pk>\d+)/$", views.BookViewSet.as_view({"get": "retrieve"})),

    # url(r'^books/latest/$', views.BookViewSet.as_view({'get': 'latest'})),
    # url(r'^books/(?P<pk>\d+)/update_bread/$', views.BookViewSet.as_view({'put': 'update_bread'})),
]


# 创建路由器
"""
DefaultRouter, SimpleRouter
两者的区别在于访问根页面的时候,DefaultRouter会有页面和提示,而SimpleRouter不提供根页面访问,直接404

"""
router = DefaultRouter()
# 注册路由
router.register(r"books",  views.BookViewSet)
# 把路由追加到urlpatterns里面
urlpatterns += router.urls
# urlpatterns = urlpatterns + router.urls